<template>
<div class="base-container">
  <div class="content">
    <router-view/>
  </div>
  <div class="tabbar">
    <var-bottom-navigation v-model:active="active" z-index="100">
      <var-bottom-navigation-item label="学习" icon="home" />
      <var-bottom-navigation-item label="分享" icon="notebook" />
      <var-bottom-navigation-item label="我" icon="account-circle" />
    </var-bottom-navigation>
  </div>
</div>
</template>

<script lang="ts" setup>
import {onMounted, ref, watch} from "vue";
import router from "@/router";

const active = ref(0)

watch(active , () => {
  switch (active.value) {
    case 0 : {
      router.push("/main/study")
      break;
    }
    case 1 : {
      router.push("/main/share")
      break;
    }
    case 2 : {
      router.push("/main/personal")
      break;
    }
  }
})

onMounted(() => {
  switch (router.currentRoute.value.path) {
    case '/main/study': {
      active.value = 0;
      break;
    }
    case '/main/share': {
      active.value = 1;
      break;
    }
    case '/main/personal': {
      active.value = 2;
      break;
    }
    case '/main/settings': {
      active.value = 2;
      break;
    }
  }

})
</script>

<style scoped>
html,
body {
  margin:0;
  padding:0;
  height:100%;
}
.base-container{
  position: relative;
  width: 100%;
  height: 100%;
}
.content{
  position: absolute;
  width: 100%;
  height: 93%;
  overflow-y: auto;
  background-color: #f8f8f8;
}
.tabbar{
  position: sticky;
  top: 100%;
  width: 100%;
  z-index: 100;
}
</style>